package com.liming.user.controller;

import com.liming.common.pojo.vo.coupon.mini.MiniProductUserCouponVO;
import com.liming.common.result.LMResult;
import com.liming.coupon.client.CouponUserClient;
import com.liming.user.service.CouponService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author liming
 * @date 2025/1/19
 */
@Slf4j
@RestController
@AllArgsConstructor
@Tag(name = "优惠券接口-Web")
@RequestMapping("/user/coupon")
public class CouponController {

    private final CouponService couponService;
    private final CouponUserClient couponUserClient;

    @Operation(summary = "领取优惠券")
    @PostMapping("get/{id}")
    public LMResult<Boolean> get(@PathVariable Long id) {
        Boolean result = couponUserClient.get(id);
        return LMResult.success(result);
    }

//    @Operation(summary = "优惠券是否可用")
//    @PostMapping("check_available")
//    public LMResult<Boolean> checkAvailable(@RequestBody CouponValidDTO couponValidDTO) {
//        Boolean result = couponUserClient.checkAvailable(couponValidDTO);
//        return LMResult.success(result);
//    }

    @Operation(summary = "根据优惠券ID列表 查询 用户还能领取的优惠券信息")
    @PostMapping("coupon_detail_list")
    public LMResult<List<MiniProductUserCouponVO>> couponDetailList(@RequestBody List<Long> couponIds) {
        return LMResult.success(couponService.couponDetailList(couponIds));
    }

}
